<?php


abstract class BaseTblPin extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $f_id;


	
	protected $f_dist_id = 0;


	
	protected $f_dist_id2 = 0;


	
	protected $f_pin;


	
	protected $f_cps = 0;


	
	protected $f_unit = 0;


	
	protected $f_type;


	
	protected $f_action;


	
	protected $f_action_datetime;


	
	protected $f_created_by = 0;


	
	protected $f_created_datetime;


	
	protected $f_is_calc = 0;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getFId()
	{

		return $this->f_id;
	}

	
	public function getFDistId()
	{

		return $this->f_dist_id;
	}

	
	public function getFDistId2()
	{

		return $this->f_dist_id2;
	}

	
	public function getFPin()
	{

		return $this->f_pin;
	}

	
	public function getFCps()
	{

		return $this->f_cps;
	}

	
	public function getFUnit()
	{

		return $this->f_unit;
	}

	
	public function getFType()
	{

		return $this->f_type;
	}

	
	public function getFAction()
	{

		return $this->f_action;
	}

	
	public function getFActionDatetime($format = 'Y-m-d H:i:s')
	{

		if ($this->f_action_datetime === null || $this->f_action_datetime === '') {
			return null;
		} elseif (!is_int($this->f_action_datetime)) {
						$ts = strtotime($this->f_action_datetime);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [f_action_datetime] as date/time value: " . var_export($this->f_action_datetime, true));
			}
		} else {
			$ts = $this->f_action_datetime;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getFCreatedBy()
	{

		return $this->f_created_by;
	}

	
	public function getFCreatedDatetime($format = 'Y-m-d H:i:s')
	{

		if ($this->f_created_datetime === null || $this->f_created_datetime === '') {
			return null;
		} elseif (!is_int($this->f_created_datetime)) {
						$ts = strtotime($this->f_created_datetime);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [f_created_datetime] as date/time value: " . var_export($this->f_created_datetime, true));
			}
		} else {
			$ts = $this->f_created_datetime;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getFIsCalc()
	{

		return $this->f_is_calc;
	}

	
	public function setFId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->f_id !== $v) {
			$this->f_id = $v;
			$this->modifiedColumns[] = TblPinPeer::F_ID;
		}

	} 

	
	public function setFDistId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->f_dist_id !== $v || $v === 0) {
			$this->f_dist_id = $v;
			$this->modifiedColumns[] = TblPinPeer::F_DIST_ID;
		}

	} 

	
	public function setFDistId2($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->f_dist_id2 !== $v || $v === 0) {
			$this->f_dist_id2 = $v;
			$this->modifiedColumns[] = TblPinPeer::F_DIST_ID2;
		}

	} 

	
	public function setFPin($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->f_pin !== $v) {
			$this->f_pin = $v;
			$this->modifiedColumns[] = TblPinPeer::F_PIN;
		}

	} 

	
	public function setFCps($v)
	{

		if ($this->f_cps !== $v || $v === 0) {
			$this->f_cps = $v;
			$this->modifiedColumns[] = TblPinPeer::F_CPS;
		}

	} 

	
	public function setFUnit($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->f_unit !== $v || $v === 0) {
			$this->f_unit = $v;
			$this->modifiedColumns[] = TblPinPeer::F_UNIT;
		}

	} 

	
	public function setFType($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->f_type !== $v) {
			$this->f_type = $v;
			$this->modifiedColumns[] = TblPinPeer::F_TYPE;
		}

	} 

	
	public function setFAction($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->f_action !== $v) {
			$this->f_action = $v;
			$this->modifiedColumns[] = TblPinPeer::F_ACTION;
		}

	} 

	
	public function setFActionDatetime($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [f_action_datetime] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->f_action_datetime !== $ts) {
			$this->f_action_datetime = $ts;
			$this->modifiedColumns[] = TblPinPeer::F_ACTION_DATETIME;
		}

	} 

	
	public function setFCreatedBy($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->f_created_by !== $v || $v === 0) {
			$this->f_created_by = $v;
			$this->modifiedColumns[] = TblPinPeer::F_CREATED_BY;
		}

	} 

	
	public function setFCreatedDatetime($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [f_created_datetime] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->f_created_datetime !== $ts) {
			$this->f_created_datetime = $ts;
			$this->modifiedColumns[] = TblPinPeer::F_CREATED_DATETIME;
		}

	} 

	
	public function setFIsCalc($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->f_is_calc !== $v || $v === 0) {
			$this->f_is_calc = $v;
			$this->modifiedColumns[] = TblPinPeer::F_IS_CALC;
		}

	} 

	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->f_id = $rs->getInt($startcol + 0);

			$this->f_dist_id = $rs->getInt($startcol + 1);

			$this->f_dist_id2 = $rs->getInt($startcol + 2);

			$this->f_pin = $rs->getString($startcol + 3);

			$this->f_cps = $rs->getFloat($startcol + 4);

			$this->f_unit = $rs->getInt($startcol + 5);

			$this->f_type = $rs->getString($startcol + 6);

			$this->f_action = $rs->getString($startcol + 7);

			$this->f_action_datetime = $rs->getTimestamp($startcol + 8, null);

			$this->f_created_by = $rs->getInt($startcol + 9);

			$this->f_created_datetime = $rs->getTimestamp($startcol + 10, null);

			$this->f_is_calc = $rs->getInt($startcol + 11);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 12; 
		} catch (Exception $e) {
			throw new PropelException("Error populating TblPin object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TblPinPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			TblPinPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TblPinPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 
		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


			
			if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = TblPinPeer::doInsert($this, $con);
					$affectedRows += 1; 
										 
										 

					$this->setFId($pk);  

					$this->setNew(false);
				} else {
					$affectedRows += TblPinPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 

	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = TblPinPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TblPinPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getFId();
				break;
			case 1:
				return $this->getFDistId();
				break;
			case 2:
				return $this->getFDistId2();
				break;
			case 3:
				return $this->getFPin();
				break;
			case 4:
				return $this->getFCps();
				break;
			case 5:
				return $this->getFUnit();
				break;
			case 6:
				return $this->getFType();
				break;
			case 7:
				return $this->getFAction();
				break;
			case 8:
				return $this->getFActionDatetime();
				break;
			case 9:
				return $this->getFCreatedBy();
				break;
			case 10:
				return $this->getFCreatedDatetime();
				break;
			case 11:
				return $this->getFIsCalc();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = TblPinPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getFId(),
			$keys[1] => $this->getFDistId(),
			$keys[2] => $this->getFDistId2(),
			$keys[3] => $this->getFPin(),
			$keys[4] => $this->getFCps(),
			$keys[5] => $this->getFUnit(),
			$keys[6] => $this->getFType(),
			$keys[7] => $this->getFAction(),
			$keys[8] => $this->getFActionDatetime(),
			$keys[9] => $this->getFCreatedBy(),
			$keys[10] => $this->getFCreatedDatetime(),
			$keys[11] => $this->getFIsCalc(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TblPinPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setFId($value);
				break;
			case 1:
				$this->setFDistId($value);
				break;
			case 2:
				$this->setFDistId2($value);
				break;
			case 3:
				$this->setFPin($value);
				break;
			case 4:
				$this->setFCps($value);
				break;
			case 5:
				$this->setFUnit($value);
				break;
			case 6:
				$this->setFType($value);
				break;
			case 7:
				$this->setFAction($value);
				break;
			case 8:
				$this->setFActionDatetime($value);
				break;
			case 9:
				$this->setFCreatedBy($value);
				break;
			case 10:
				$this->setFCreatedDatetime($value);
				break;
			case 11:
				$this->setFIsCalc($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = TblPinPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setFId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setFDistId($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setFDistId2($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setFPin($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setFCps($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setFUnit($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setFType($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setFAction($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setFActionDatetime($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setFCreatedBy($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setFCreatedDatetime($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setFIsCalc($arr[$keys[11]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(TblPinPeer::DATABASE_NAME);

		if ($this->isColumnModified(TblPinPeer::F_ID)) $criteria->add(TblPinPeer::F_ID, $this->f_id);
		if ($this->isColumnModified(TblPinPeer::F_DIST_ID)) $criteria->add(TblPinPeer::F_DIST_ID, $this->f_dist_id);
		if ($this->isColumnModified(TblPinPeer::F_DIST_ID2)) $criteria->add(TblPinPeer::F_DIST_ID2, $this->f_dist_id2);
		if ($this->isColumnModified(TblPinPeer::F_PIN)) $criteria->add(TblPinPeer::F_PIN, $this->f_pin);
		if ($this->isColumnModified(TblPinPeer::F_CPS)) $criteria->add(TblPinPeer::F_CPS, $this->f_cps);
		if ($this->isColumnModified(TblPinPeer::F_UNIT)) $criteria->add(TblPinPeer::F_UNIT, $this->f_unit);
		if ($this->isColumnModified(TblPinPeer::F_TYPE)) $criteria->add(TblPinPeer::F_TYPE, $this->f_type);
		if ($this->isColumnModified(TblPinPeer::F_ACTION)) $criteria->add(TblPinPeer::F_ACTION, $this->f_action);
		if ($this->isColumnModified(TblPinPeer::F_ACTION_DATETIME)) $criteria->add(TblPinPeer::F_ACTION_DATETIME, $this->f_action_datetime);
		if ($this->isColumnModified(TblPinPeer::F_CREATED_BY)) $criteria->add(TblPinPeer::F_CREATED_BY, $this->f_created_by);
		if ($this->isColumnModified(TblPinPeer::F_CREATED_DATETIME)) $criteria->add(TblPinPeer::F_CREATED_DATETIME, $this->f_created_datetime);
		if ($this->isColumnModified(TblPinPeer::F_IS_CALC)) $criteria->add(TblPinPeer::F_IS_CALC, $this->f_is_calc);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(TblPinPeer::DATABASE_NAME);

		$criteria->add(TblPinPeer::F_ID, $this->f_id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getFId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setFId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setFDistId($this->f_dist_id);

		$copyObj->setFDistId2($this->f_dist_id2);

		$copyObj->setFPin($this->f_pin);

		$copyObj->setFCps($this->f_cps);

		$copyObj->setFUnit($this->f_unit);

		$copyObj->setFType($this->f_type);

		$copyObj->setFAction($this->f_action);

		$copyObj->setFActionDatetime($this->f_action_datetime);

		$copyObj->setFCreatedBy($this->f_created_by);

		$copyObj->setFCreatedDatetime($this->f_created_datetime);

		$copyObj->setFIsCalc($this->f_is_calc);


		$copyObj->setNew(true);

		$copyObj->setFId(NULL); 

	}

	
	public function copy($deepCopy = false)
	{
		
		$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new TblPinPeer();
		}
		return self::$peer;
	}

} 